//
//  HeadlineView.m
//  UI15_太平洋电脑网
//
//  Created by dllo on 16/3/23.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "HeadlineView.h"
#import "Data.h"
#import "Headline.h"
#import "Head.h"
#import "UIImageView+WebCache.h"
#import "CollectionCell.h"
#import "HeadCell.h"
#import "SubOfHeadline.h"
#import "PicShowModel.h"
#import "PicShowCell.h"
#import "PlayCell.h"
#import "BarCell.h"
#import "PicCell.h"
#import "SaleCell.h"
#import "GDRNavigationBarView.h"
#define     WIDTH  self.view.frame.size.width
#define HEIGHT  self.view.frame.size.height
#import "DeleteButton.h"


@interface HeadlineView ()<UICollectionViewDataSource,UICollectionViewDelegate,UITableViewDataSource,UITableViewDelegate,UIScrollViewDelegate>

@property (nonatomic,retain)GDRNavigationBarView *naTableView;
@property (nonatomic,retain)UICollectionView *barCollection;
@property (nonatomic,retain)NSArray *barArray;
@property (nonatomic,retain)UIScrollView *scrollView;

@property (nonatomic,retain)UITableView *headlineTableView;
@property (nonatomic,retain)UICollectionView *collectionView;
@property (nonatomic,retain)NSMutableArray *lunBoArray;

@property (nonatomic,retain)NSMutableArray *headlineArray;
@property (nonatomic,retain)NSMutableArray *segValue;

@property (nonatomic,retain)UITableView *newsTableView;
@property (nonatomic,retain)NSMutableArray *newsArray;

@property (nonatomic,retain)UITableView *assessmentTableView;
@property (nonatomic,retain)NSMutableArray *assessmentArray;  //一样

@property (nonatomic,retain)UITableView *picShowTableView;
@property (nonatomic,retain)NSMutableArray *picShowArray;

@property (nonatomic,retain)UITableView *phoneTableView;
@property (nonatomic,retain)NSMutableArray *phoneArray;  //一样

@property (nonatomic,retain)UITableView *playTableView;
@property (nonatomic,retain)NSMutableArray *playArray;

@property (nonatomic,retain)UITableView *lisenTableView;
@property (nonatomic,retain)NSMutableArray *lisenArray;  //一样

@end
        //系统是最后才解析数据遇到json就最后执行       //不同的cell   标题
@implementation HeadlineView

- (void)viewDidLoad {
    [super viewDidLoad];    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.translucent = NO;
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:27 / 255.0 green:163 / 255.0 blue:217/255.0 alpha:1];
    self.tabBarController.hidesBottomBarWhenPushed = YES;
    
    UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 10, 414 - 69, 44)];
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace  target:nil action:nil];
    negativeSpacer.width = -20;           //这个数值可以根据情况自由变化
    self.navigationItem.leftBarButtonItems = @[negativeSpacer, backItem];
    self.barArray = @[@"头条",@"新闻",@"测评",@"图赏",@"手机",@"直播",@"试听"];
    self.naTableView = [[GDRNavigationBarView alloc]initWithFrame:CGRectMake(0, 0, 414, 40) withWidth:414 withArray:self.barArray];
    [btn addSubview:self.naTableView];
    [_naTableView release];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(414-40, 20, 20, 20);
    [button addTarget:self action:@selector(rightAcion:) forControlEvents:UIControlEventTouchUpInside];
    [button setImage:[UIImage imageNamed:@"iconfont-xiayige.png"] forState:UIControlStateNormal];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button];
    
//    [self createData];
//    [self createView];
//    [self createHeadlineView];  //头条
//    [self createNewsTableView];   //新闻
//    [self createAssessmentTableView];  //测评
//    [self createpicShowTableView];    //图赏
//    [self createphoneTableView];
//    [self createplayTableView];
//    [self createlisenTableView];
    
}

- (void)rightAcion:(UIButton *)button{
    DeleteButton *deleteView = [[DeleteButton alloc]init];
    [self presentViewController:deleteView animated:YES completion:^{}];
    [deleteView release];
}







- (void)createView{
    self.scrollView = [[UIScrollView alloc]initWithFrame:self.view.frame];    //用的UIView的初始化方法
    self.scrollView .backgroundColor =[UIColor cyanColor];
    self.scrollView .pagingEnabled = YES; /*按 页 去 滑 动*/
    self.scrollView .bounces = NO;     /*设置边界回弹*/
    self.scrollView .showsHorizontalScrollIndicator = NO;  //隐藏水平滚动条
    self.scrollView.delegate = self;
    [self.view addSubview: self.scrollView ];
    [ self.scrollView  release];
    self.scrollView .contentSize = CGSizeMake(414 * 7, 0);
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(deliverValue:) name:@"123" object:nil];
}
//不同界面跳到不同的button
- (void)deliverValue:(NSNotification *)notification{
    NSString *str = [notification object];
    CGFloat temp = [str intValue];
    self.scrollView.contentOffset = CGPointMake(temp *WIDTH, 0);
}
#pragma mark - 问题1  scrollView  很多double签订了scrollView的协议方法
// 点击button 跳到对应的界面
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if ([scrollView isEqual:self.scrollView]) {
        [self.naTableView deliver:scrollView];
     }
}
- (void)createHeadlineView{
    self.headlineTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 736 - 64 - 49)];
    [ self.scrollView  addSubview:self.headlineTableView];
    [_headlineTableView release];
    self.headlineTableView.contentInset =UIEdgeInsetsMake(200, 0, 0, 0);
    self.headlineTableView.delegate =self;
   self.headlineTableView.dataSource = self;
    self.headlineTableView.rowHeight = 120;
    self.headlineTableView.showsHorizontalScrollIndicator = NO;  //隐藏水平滚动图
    self.headlineTableView.showsVerticalScrollIndicator = NO;  //隐藏数值滚动图
    [self.headlineTableView registerClass:[HeadCell class] forCellReuseIdentifier:NSStringFromClass([HeadCell class])];
                                           /* 创 建 轮 播 图 */
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
    layout.itemSize = CGSizeMake(self.view.frame.size.width, 170);
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    layout.minimumInteritemSpacing = 0;
    layout.minimumLineSpacing = 0;
                                        /*collection 轮 播 图*/
    self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, -200, self.view.frame.size.width, 170) collectionViewLayout:layout];
    [self.headlineTableView addSubview:self.collectionView];
    self.collectionView.backgroundColor = [UIColor yellowColor];
    [_collectionView release];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    self.collectionView.bounces = NO;        //隐藏边界回弹
    self.collectionView.pagingEnabled = YES; //按页区滑动
    self.collectionView.showsHorizontalScrollIndicator = NO;   //混动跳
    [self.collectionView registerClass:[CollectionCell class] forCellWithReuseIdentifier:NSStringFromClass([CollectionCell class])];
    [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(changePic) userInfo:nil repeats:YES];     //图片转动
                                              /* 轮 播 图 下 面 的 字 */
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, -30, 350, 30)];
    [self.headlineTableView addSubview:label];
    label.tag = 1000;
    [label release];
    UILabel *number = [[UILabel alloc]initWithFrame:CGRectMake(350, -30, 414-350, 30)];
    [self.headlineTableView addSubview:number];
    number.tag = 1001;
    [number release];
}
                                                          //轮播图方法
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    if ([collectionView isEqual:self.collectionView]) {
    return self.lunBoArray.count + 1;
    }else{
        return self.barArray.count;
    }
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    if ([collectionView isEqual:self.collectionView]) {
        CollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([CollectionCell class]) forIndexPath:indexPath];
        if (indexPath.row < self.lunBoArray.count ) {
            Headline *headline = self.lunBoArray[indexPath.row];
            [cell.imageView  sd_setImageWithURL:[NSURL URLWithString:headline.image]];
            UILabel *label = [self.view viewWithTag:1000];
            label.text = headline.title;
            UILabel *number = [self.view viewWithTag:1001];
            number.text =[NSString stringWithFormat:@"%ld / 6",indexPath.row + 1];
            return cell;
        }else{
            Headline *headline = self.lunBoArray[0];
            [cell.imageView  sd_setImageWithURL:[NSURL URLWithString:headline.image]];
            UILabel *label = [self.view viewWithTag:1000];
            label.text = headline.title;
            UILabel *number = [self.view viewWithTag:1001];
            number.text =[NSString stringWithFormat:@"1 / 6"];
            return cell;
        }
    }else {
        BarCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([BarCell class]) forIndexPath:indexPath];
        cell.label.text =self.barArray[indexPath.row];
        return cell;
    }
}
///图片滚动
- (void)changePic{
     [self.collectionView setContentOffset:CGPointMake( self.collectionView.contentOffset.x + 414,  0) animated:YES];
    if (self.collectionView.contentOffset.x == 414 * 6) {
        self.collectionView.contentOffset = CGPointMake(0, 0);
    }
}
- (void)createNewsTableView{
    self.newsTableView = [[UITableView alloc]initWithFrame:CGRectMake(414,0, 414, 736 - 64 - 49)];
    [ self.scrollView  addSubview:self.newsTableView];
    self.newsTableView.backgroundColor = [UIColor whiteColor];
    [_newsTableView release];
    self.newsTableView.delegate =self;
    self.newsTableView.dataSource = self;
    self.newsTableView.rowHeight = 120;
    self.newsTableView.showsHorizontalScrollIndicator = NO;  //隐藏水平滚动图
    self.newsTableView.showsVerticalScrollIndicator = NO;  //隐藏数值滚动图
    [self.newsTableView registerClass:[HeadCell class] forCellReuseIdentifier:NSStringFromClass([HeadCell class])];
}
- (void)createAssessmentTableView{
    self.assessmentTableView = [[UITableView alloc]initWithFrame:CGRectMake( 414 * 2,0, 414, 736 - 64 - 49)];
    [ self.scrollView  addSubview:self.assessmentTableView];
    self.assessmentTableView.backgroundColor = [UIColor whiteColor];
    [_assessmentTableView release];
    self.assessmentTableView.delegate =self;
    self.assessmentTableView.dataSource = self;
    self.assessmentTableView.rowHeight = 120;
    self.assessmentTableView.showsHorizontalScrollIndicator = NO;  //隐藏水平滚动图
    self.assessmentTableView.showsVerticalScrollIndicator = NO;  //隐藏数值滚动图
    [self.assessmentTableView registerClass:[HeadCell class] forCellReuseIdentifier:NSStringFromClass([HeadCell class])];
}
- (void)createpicShowTableView{
    self.picShowTableView = [[UITableView alloc]initWithFrame:CGRectMake( 414 * 3, 0,414, 736 - 64 - 49)];
    [ self.scrollView  addSubview:self.picShowTableView];
    [_picShowTableView release];
    self.picShowTableView.delegate =self;
    self.picShowTableView.dataSource = self;
    self.picShowTableView.rowHeight = 230;
    self.picShowTableView.showsHorizontalScrollIndicator = NO;  //隐藏水平滚动图
    self.picShowTableView.showsVerticalScrollIndicator = NO;  //隐藏数值滚动图
    [self.picShowTableView registerClass:[PicShowCell class] forCellReuseIdentifier:NSStringFromClass([PicShowCell class])];
    self.picShowTableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
}
- (void)createphoneTableView{
    self.phoneTableView = [[UITableView alloc]initWithFrame:CGRectMake( 414 * 4, 0,414, 736 - 49 - 64)];
    [ self.scrollView  addSubview:self.phoneTableView];
    [_phoneTableView release];
    self.phoneTableView.delegate =self;
    self.phoneTableView.dataSource = self;
    self.phoneTableView.rowHeight = 120;
    self.phoneTableView.showsHorizontalScrollIndicator = NO;  //隐藏水平滚动图
    self.phoneTableView.showsVerticalScrollIndicator = NO;  //隐藏数值滚动图
    [self.phoneTableView registerClass:[HeadCell class] forCellReuseIdentifier:NSStringFromClass([HeadCell class])];
}
- (void)createplayTableView{
    self.playTableView = [[UITableView alloc]initWithFrame:CGRectMake( 414 * 5,0, 414, 623)];
    [ self.scrollView  addSubview:self.playTableView];
    [_playTableView release];
    self.playTableView.delegate =self;
    self.playTableView.dataSource = self;
    self.playTableView.rowHeight = 260;
    self.playTableView.showsHorizontalScrollIndicator = NO;  //隐藏水平滚动图
    self.playTableView.showsVerticalScrollIndicator = NO;  //隐藏数值滚动图
    [self.playTableView registerClass:[PlayCell class] forCellReuseIdentifier:NSStringFromClass([PlayCell class])];
}
- (void)createlisenTableView{
    self.lisenTableView = [[UITableView alloc]initWithFrame:CGRectMake( 414 * 6,0, 414, 623)];
    [ self.scrollView  addSubview:self.lisenTableView];
    [_lisenTableView release];
    self.lisenTableView.delegate =self;
    self.lisenTableView.dataSource = self;
    self.lisenTableView.rowHeight = 120;
    self.lisenTableView.showsHorizontalScrollIndicator = NO;  //隐藏水平滚动图
    self.lisenTableView.showsVerticalScrollIndicator = NO;  //隐藏数值滚动图
    [self.lisenTableView registerClass:[HeadCell class] forCellReuseIdentifier:NSStringFromClass([HeadCell class])];
}

                                                /* tableView 方 法 */
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if ([tableView isEqual:self.headlineTableView]) {
            return self.headlineArray.count;
    }else if([tableView isEqual:self.newsTableView]){
        return self.newsArray.count;
    }else if([tableView isEqual:self.assessmentTableView]){
        return self.assessmentArray.count;
    }else if([tableView isEqual:self.picShowTableView]){
        return self.picShowArray.count;
    }else if([tableView isEqual:self.phoneTableView]){
        return self.phoneArray.count;
    }else if([tableView isEqual:self.playTableView]){
        return self.playArray.count;
    }else if([tableView isEqual:self.lisenTableView]){
        return self.lisenArray.count;
    }
    return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ //return 本方法执行一次
    if ([tableView isEqual:self.headlineTableView]) {
        Head *head = self.headlineArray[indexPath.row];
        for (NSNumber *number in self.segValue) {
            if (indexPath.row +1== number.integerValue &&  head.informationType.intValue ==3) {
                static NSString *reuse = @"resue1";
                PicCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
                if (!cell) {
                    cell = [[[PicCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuse]autorelease];
                }
                cell.titleLabel.text = head.title;
                [cell.firstImageView  sd_setImageWithURL:[NSURL URLWithString:head.imgUrls[0]]];
                [cell.secondImageView  sd_setImageWithURL:[NSURL URLWithString:head.imgUrls[1]]];
                [cell.thirdImageView  sd_setImageWithURL:[NSURL URLWithString:head.imgUrls[2]]];
                cell.pubDateLabel.text = head.pubDate;
                cell.imgCountLabel.text = [NSString stringWithFormat:@"%@张", head.imgCount.stringValue];
                return cell;
            }
            if (indexPath.row +1 == number.integerValue &&  head.informationType.intValue == 6) {
                static NSString *reuse = @"resue2";
                SaleCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
                if (!cell) {
                    cell = [[[SaleCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuse]autorelease];
                }
                [cell.picImageView sd_setImageWithURL:[NSURL URLWithString:head.image]];
                cell.titleLabel.text = head.title;
                cell.pubDateLable.text = head.pubDate;
                return cell;
            }
        }
        static NSString *reuse = @"resue";
        HeadCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
        if (!cell) {
            cell = [[[HeadCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuse]autorelease];
        }
        [cell.picImageView sd_setImageWithURL:[NSURL URLWithString:head.image]];
        cell.titleLabel.text = head.title;
        cell.pubDateLable.text = head.pubDate;
        NSString *num = [head.cmtCount.stringValue stringByAppendingString:@"评论"];
        cell.cmtCountLable.text = num;
        return cell;
    }else if([tableView isEqual:self.newsTableView]){
        HeadCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([HeadCell class]) forIndexPath:indexPath];
        Head *head = self.newsArray[indexPath.row];
        [cell.picImageView sd_setImageWithURL:[NSURL URLWithString:head.image]];
        cell.titleLabel.text = head.title;
        cell.pubDateLable.text = head.pubDate;
        NSString *num = [head.cmtCount.stringValue stringByAppendingString:@"评论"];
        cell.cmtCountLable.text = num;
        return cell;
    }else if([tableView isEqual:self.assessmentTableView]){
        HeadCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([HeadCell class]) forIndexPath:indexPath];
        Head *head = self.assessmentArray[indexPath.row];
        [cell.picImageView sd_setImageWithURL:[NSURL URLWithString:head.image]];
        cell.titleLabel.text = head.title;
        cell.pubDateLable.text = head.pubDate;
        NSString *num = [head.cmtCount.stringValue stringByAppendingString:@"评论"];
        cell.cmtCountLable.text = num;
        return cell;
    }else if([tableView isEqual:self.picShowTableView]){
        PicShowCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([PicShowCell class]) forIndexPath:indexPath];
        PicShowModel *picShow = self.picShowArray[indexPath.row];
        [cell.picView sd_setImageWithURL:[NSURL URLWithString:picShow.cover]];
        cell.titeLabel.text = picShow.name;
        NSString *num = [ picShow.photoCount.stringValue stringByAppendingString:@"图"];
        cell.numberLabel.text = num;
        return cell;
    }else if([tableView isEqual:self.phoneTableView]){
        HeadCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([HeadCell class]) forIndexPath:indexPath];
        Head *head = self.phoneArray[indexPath.row];
        [cell.picImageView sd_setImageWithURL:[NSURL URLWithString:head.image]];
        cell.titleLabel.text = head.title;
        cell.pubDateLable.text = head.pubDate;
        NSString *num = [head.cmtCount.stringValue stringByAppendingString:@"评论"];
        cell.cmtCountLable.text =num;
        return cell;
    }else if([tableView isEqual:self.playTableView]){
        PlayCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([PlayCell class]) forIndexPath:indexPath];
        Head *head = self.playArray[indexPath.row];
        [cell.picView sd_setImageWithURL:[NSURL URLWithString:head.image]];
        cell.titleLabel.text = head.title;
        if ([head.status isEqualToString:@"正在直播"] ) {
            cell.zhiBoPicView.image = [UIImage imageNamed:@"iconfont-zhibokaiqizhibo.png"];
            cell.zhiBoLabel.text = @"直播中";
        }else{
            cell.zhiBoPicView.image = [UIImage imageNamed:@"iconfont-jieshu.png"];
            cell.zhiBoLabel.text = @"已结束";
        }
        cell.timeLabel.text = head.pubTime;
        cell.pLLabel.text = head.cmtCount.stringValue;
        return cell;
    }else if([tableView isEqual:self.lisenTableView]){
        HeadCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([HeadCell class]) forIndexPath:indexPath];
        Head *head = self.lisenArray[indexPath.row];
        [cell.picImageView sd_setImageWithURL:[NSURL URLWithString:head.image]];
        cell.titleLabel.text = head.title;
        cell.pubDateLable.text = head.pubDate;
        NSString *num = [head.cmtCount.stringValue stringByAppendingString:@"评论"];
        cell.cmtCountLable.text =num;
        return cell;
    }
    return nil;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    SubOfHeadline *subView = [[SubOfHeadline alloc]init];
    //self.tabBarController.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:subView animated:YES];
    [subView release];
     Head *head = self.headlineArray[indexPath.row];
    subView.URL = head.url;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([tableView isEqual:self.headlineTableView]) {
        Head *head = self.headlineArray[indexPath.row];
        for (NSNumber *number in self.segValue) {
            if (indexPath.row +1== number.integerValue &&  head.informationType.intValue ==3) {
                return 200.00;
            }
        }
    }
    if([tableView isEqual:self.picShowTableView]){
        return 230.0;
    }
    if ([tableView isEqual:self.playTableView]) {
        return 260;
    }
    return 120.00;
}

- (void)createData{
    [Data netWorkingWithURL:@"http://mrobot.pconline.com.cn/v2/cms/channels/999?pageNo=1&pageSize=20&appVersion=4.4.1" block:^(id result) {
        NSDictionary *dic = result;
        NSArray *array = dic[@"articleList"];
        self.headlineArray = [NSMutableArray array];     // 头条
        for (NSDictionary *dic in array) {
            Head *dictionary = [[Head alloc]init];
            [dictionary setValuesForKeysWithDictionary:dic];
            [self.headlineArray addObject:dictionary];
            [dictionary release];
        }
        
        NSArray *adArray = dic[@"topArticle"];
        self.segValue = [NSMutableArray array];
        for (NSDictionary *dic in adArray) {
            Head *dictionary = [[Head alloc]init];
            [dictionary setValuesForKeysWithDictionary:dic];
            if (dictionary.seq.intValue <= self.headlineArray.count) {
                [self.headlineArray  insertObject:dictionary atIndex:dictionary.seq.intValue - 1];
                [self.segValue addObject:dictionary.seq];
            }
            [dictionary release];
        }
        
        NSArray *lunBoArray = dic[@"focus"];
        self.lunBoArray = [NSMutableArray array];
        for (NSDictionary *dic in lunBoArray) {
            Headline *dictionary = [[Headline alloc]init];
            [dictionary setValuesForKeysWithDictionary:dic];
            [self.lunBoArray addObject:dictionary];
            [dictionary release];
        }
        [self.collectionView reloadData];
        [self.headlineTableView reloadData];
    }];
;
    
    
    [Data netWorkingWithURL:@"http://mrobot.pconline.com.cn/v2/cms/channels/2?pageNo=1&pageSize=20&appVersion=4.4.1" block:^(id result) {
        NSDictionary *dic = result;
        NSArray *array = dic[@"articleList"];
        self.newsArray = [NSMutableArray array];        //新闻数据解析
        for (NSDictionary *dic in array) {
            Head *dictionary = [[Head alloc]init];
            [dictionary setValuesForKeysWithDictionary:dic];
            [self.newsArray addObject:dictionary];
            [dictionary release];
        }
        [self.newsTableView reloadData];

    }];
    
    [Data netWorkingWithURL:@"http://mrobot.pconline.com.cn/v2/cms/channels/4?pageNo=1&pageSize=20&appVersion=4.4.1" block:^(id result) {
        NSDictionary *dic = result;
        NSArray *array = dic[@"articleList"];
        self.assessmentArray = [NSMutableArray array];        //测评数据解析 (一样)
        for (NSDictionary *dic in array) {
            Head *dictionary = [[Head alloc]init];
            [dictionary setValuesForKeysWithDictionary:dic];
            [self.assessmentArray addObject:dictionary];
            [dictionary release];
        }
        [self.assessmentTableView reloadData];

    }];
    
    [Data netWorkingWithURL:@"http://mrobot.pconline.com.cn/v2/cms/channels/11?pageSize=20&pageNo=1" block:^(id result) {
        NSDictionary *dic = result;
        NSArray *array = dic[@"groups"];
        self.picShowArray = [NSMutableArray array];        //图赏
        for (NSDictionary *dic in array) {
            PicShowModel *dictionary = [[PicShowModel alloc]init];
            [dictionary setValuesForKeysWithDictionary:dic];
            [self.picShowArray addObject:dictionary];
            [dictionary release];
        }
        [self.picShowTableView reloadData];

    }];
    
    [Data netWorkingWithURL:@"http://mrobot.pconline.com.cn/v2/cms/channels/200?pageNo=1&pageSize=20&appVersion=4.4.1" block:^(id result) {
        NSDictionary *dic = result;
        NSArray *array = dic[@"articleList"];
        self.phoneArray = [NSMutableArray array];        //手机
        for (NSDictionary *dic in array) {
            Head *dictionary = [[Head alloc]init];
            [dictionary setValuesForKeysWithDictionary:dic];
            [self.phoneArray addObject:dictionary];
            [dictionary release];
        }
        [self.phoneTableView reloadData];

    }];

    [Data netWorkingWithURL:@"http://mrobot.pconline.com.cn/v2/cms/channels/10?pageNo=1&pageSize=20" block:^(id result) {
        NSDictionary *dic = result;
        NSArray *array = dic[@"articleList"];
        self.playArray = [NSMutableArray array];        //直播
        for (NSDictionary *dic in array) {
            Head *dictionary = [[Head alloc]init];
            [dictionary setValuesForKeysWithDictionary:dic];
            [self.playArray addObject:dictionary];
            [dictionary release];
        }
        [self.playTableView reloadData];

    }];
    
    [Data netWorkingWithURL:@"http://mrobot.pconline.com.cn/v2/cms/channels/12?pageNo=1&pageSize=20&appVersion=4.4.1" block:^(id result) {
        NSDictionary *dic = result;
        NSArray *array = dic[@"articleList"];
        self.lisenArray = [NSMutableArray array];        //试听
        for (NSDictionary *dic in array) {
            Head *dictionary = [[Head alloc]init];
            [dictionary setValuesForKeysWithDictionary:dic];
            [self.lisenArray addObject:dictionary];
            [dictionary release];
        }
        [self.lisenTableView reloadData];

    }];

    
}
































- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
